package iedcyt.acute.dataAccess.factories;


import iedcyt.acute.dataAccess.dao.htmlUnit.HashDao;
import iedcyt.acute.dataAccess.dao.htmlUnit.UTIDDao;
import iedcyt.acute.dataAccess.idao.IDao;
import iedcyt.acute.dataAccess.idao.htmlUnit.IHashDao;
import iedcyt.acute.dataAccess.idao.htmlUnit.IUTIDDao;
import iedcyt.acute.dataAccess.utils.BeansXML;
import iedcyt.acute.dataAccess.utils.Parameters;

import org.springframework.context.support.AbstractApplicationContext;
import org.springframework.context.support.FileSystemXmlApplicationContext;


public class AbsHtmlUnitFactoryDao extends AbsFactoryDao {

	private static AbsHtmlUnitFactoryDao _instance;

	private IUTIDDao _utidDao;
	private IHashDao _hashDao;
	
	private AbsHtmlUnitFactoryDao()
	{
		super();
		startDaos();
		
	}
	

	public static AbsHtmlUnitFactoryDao getInstance()
	{
		if (_instance == null) _instance = new AbsHtmlUnitFactoryDao();
		
		return _instance;
	}
	
	
	
	
	public IUTIDDao getUTIDDao() {
		return _utidDao;
	}

	public IHashDao getHashDao()
	{
		return _hashDao;
	}
	
	@Override
	protected IDao getIDao() {
		return  _utidDao;
	}


	/**
	 * @see iedcyt.acute.dataAccess.factories.AbsFactoryDao#startDaos()
	 */
	@Override
	public void startDaos() {
		AbstractApplicationContext _context = new FileSystemXmlApplicationContext(Parameters.get_instance().getBeanFile());
		_context.registerShutdownHook();
		
		_hashDao = (HashDao) _context.getBean("hashDao");
		_hashDao.create();
		_utidDao = (UTIDDao) _context.getBean("utidDao");
		
		
	}
	
	/**
	 * @see iedcyt.acute.dataAccess.factories.AbsFactoryDao#getPath()
	 */
	@Override
	public String getPath() {
		return BeansXML.getInstance().getDatabasePath("HtmlUnitDataSource");
		
	}





	


	
}
